package com.lgkj.ui;

import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ListView;

import com.lgkj.R;
import com.lgkj.adapter.ShopNameAdapter;
import com.lgkj.bean.CityShopBean;

import butterknife.BindView;

/**
 * Created by Administrator on 2018/8/14 0014.
 */

public class AdCityActivity extends BaseActivity {

    String title;
    @BindView(R.id.lv_shop)
    ListView lvShop;
    ShopNameAdapter adapter;
    private int position;
    private CityShopBean.DataBean dataBeans;

    @Override
    public int getLayoutId() {
        return R.layout.activity_ad_city;
    }

    @Override
    public void initView() {
        title = getIntent().getStringExtra("city_title");
        position = getIntent().getIntExtra("city_id", 0);
        setTitle(title);
    }

    @Override
    public void initData() {
        adapter = new ShopNameAdapter(AdCityActivity.this);
        lvShop.setAdapter(adapter);
        dataBeans = AdTextActivity.cityShopBean.getData().get(position);
        adapter.setDataBeans(dataBeans.getBarbershop_list());
        adapter.setType(dataBeans.getType());
        adapter.notifyDataSetChanged();
        adapter.setClick(new ShopNameAdapter.MyClickListener() {
            @Override
            public void clickListener(View v) {
                int i = Integer.parseInt(v.getTag().toString());
                CheckBox checkBox = (CheckBox) v;
                CityShopBean.DataBean.BarbershopListBean data = AdTextActivity.cityShopBean.getData().get(position).getBarbershop_list().get(i);
                data.setIscheck(checkBox.isChecked());
                Log.i(TAG, checkBox.isChecked() + "clickListener: " + data.getIscheck() + "," + dataBeans.getType());
            }
        });
    }


}
